/**
 * Created by tancw on 2015/8/17.
 */

;
jQuery.extend({
    download:function(s){
      var form = jQuery.createFileDownloadForm(s.url,(typeof(s.data)=='undefined'?false: s.data));
      form.submit();
      form.remove();
    },

    createFileDownloadForm: function (url, data) {
        var form = jQuery('<form action="'+ url + '" method="POST" style="display:none;"><\/form>');
        if(data){
            for(var i in data){
             jQuery('<input type="hidden" name="'+ i +'" value="'+data[i]+'"/>').appendTo(form);
            }
        }
        jQuery(form).appendTo('body');
        return form;
    }
});
